package cmd

import (
	"context"
	"gitee.com/kmyss/gf-ex/ysbuild"
	"gitee.com/kmyss/gf-ex/yscmd"
	"gitee.com/kmyss/ys-cli/internal/cmd/git"
	"gitee.com/kmyss/ys-cli/internal/cmd/go"
	"gitee.com/kmyss/ys-cli/internal/cmd/grpc"
	grpc_module "gitee.com/kmyss/ys-cli/internal/cmd/grpc-module"
	"gitee.com/kmyss/ys-cli/internal/cmd/python"
	"gitee.com/kmyss/ys-cli/internal/cmd/script"
)

type Builder struct {
	yscmd.CommandBuilderCore
}

func (b *Builder) Init(ctx context.Context) {
	b.CommandBuilderCore.Init(ctx)
	b.C.Use = ysbuild.APPName

	b.C.Run = yscmd.RootRun
	b.addCmd()
	b.addFlag()
}

func (b *Builder) addCmd() {
	b.SetChildCommands(
		&_go.Builder{},
		&python.Builder{},
		&git.Builder{},
		&script.Builder{},
		&grpc.Builder{},
		&grpc_module.Builder{},
		&yscmd.CmdShellBuilder{},
		&yscmd.CmdInstallBuilder{},
	)
	yscmd.SetDefaultCommand(b)

}

func (b *Builder) addFlag() {
	yscmd.SetDefaultFlag(b)
}
